import 'package:flutter/material.dart';
import 'package:provide/provide.dart';
import '../provide/details_info.dart';
import 'package:flutter_html/flutter_html.dart';
import '../provide/details_info.dart';
import '../provide/setting.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class DetailsWeb extends StatelessWidget {
  
  @override
  Widget build(BuildContext context) {
    var goodsDetail= Provide.value<DetailsInfoProvide>(context).goodsInfo['DETAIL'];
    return  Provide<DetailsInfoProvide>(
        
        builder: (context,child,val){
           var isLeft = Provide.value<DetailsInfoProvide>(context).isLeft;
           if(isLeft){
             return  Container(
                child: Provide<SettingProvide>(
                builder: (context,child,val){
                  return val.noImage?Image.asset('images/noImage.png')
                                    :Html(data:goodsDetail);
                },
              ),
            );
           }else{
            return Container(
              width: ScreenUtil().setWidth(750),
              padding: EdgeInsets.all(10),
              alignment: Alignment.center,
              child: Column(
                children: val.comment.map((i){
                  return _comment(i);
                }).toList(),
              )
            );
           }
        },
      );
  }

  // 商品评论单项
  Widget _comment(i){
    return Container(
      width: ScreenUtil().setWidth(750),
      padding: EdgeInsets.only(bottom: ScreenUtil().setHeight(10)),
      decoration: BoxDecoration(
        border: Border(bottom: BorderSide(width: 1,color: Colors.black12))
      ),
      child: Row(
        children: <Widget>[
          Container(
            width: ScreenUtil().setWidth(150),
            child: Text(i['username']),
          ),
          Container(
            width: ScreenUtil().setWidth(500),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Text('第${i['count']}楼'),
                Container(
                  child: Text(i['comment']),
                )
              ],
            ),
          )
        ],
      ),
    );
  }
}